package com.example.courseselectionsystemconsume.listener;

import com.example.courseselectionsystemconsume.timerTasks.service.Timer1Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

/**
 * @description: TODO
 * @author: Tokyo_God
 * @date: 2021/1/9 21:53
 * Role of:
 * @version: v1.0
 */
@Component
public class QueueListener {
    //操作定时器1
    @Autowired
    Timer1Service timer1Service;

    @JmsListener(destination = "${queueName}",
            containerFactory = "jmsListenerContainerQueue")
    public void receive(String str){
        System.out.println("queue:"+str+"//////////////////////进入监听器选课///////////////////////////");
        //如果他是选课
        if(str.equals("addCard")){
            System.out.println("是否关闭："+timer1Service.isClose());
            //如果定时器它关了  那么我给他启动起来  好让它继续操作
            if(timer1Service.isClose()){
                timer1Service.startCron();
            }
        }
    }
}
